#!/bin/bash

echo "🚀 设置本地链 localhost:8545 配置..."

# 检查本地链是否运行
echo "📡 检查本地链连接..."
if curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545 > /dev/null 2>&1; then
    echo "✅ 本地链 localhost:8545 正在运行"
else
    echo "❌ 本地链 localhost:8545 未运行，请先启动本地链"
    echo "💡 提示：可以使用以下命令启动本地链："
    echo "   - Hardhat: npx hardhat node"
    echo "   - Ganache: npx ganache-cli --port 8545"
    echo "   - Anvil: anvil --port 8545"
    exit 1
fi

echo "🔧 配置完成！"
echo "📋 配置摘要："
echo "   - 本地链 ID: 31337"
echo "   - RPC URL: http://localhost:8545"
echo "   - 默认链: LOCALHOST (开发环境)"
echo "   - 支持的功能: Swap, Farms, Pools, Lottery 等"

echo ""
echo "🔄 请重启开发服务器以应用配置："
echo "   pnpm run dev"
